package com.yuxi.Dao.Impl;

import java.io.Serializable;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.yuxi.Dao.InformationFlowDao;
import com.yuxi.Entity.InformationFlow;

@Repository
public class InformationFlowDaoImpl extends BaseDaoImpl<Serializable, Serializable> implements InformationFlowDao {
	private Logger logger=LoggerFactory.getLogger(InformationFlowDaoImpl.class);
	public InformationFlowDaoImpl(){
		super(InformationFlow.class);
	}
	@Override
	public InformationFlow getFlow(Integer iFlowId) {
		// TODO Auto-generated method stub
		return (InformationFlow) super.get(iFlowId);
	}

	@Override
	public InformationFlow addFlow(InformationFlow iFlow) {
		// TODO Auto-generated method stub
		return (InformationFlow) super.addAndReturn(iFlow);
	}

	@Override
	public void deleteFlow(InformationFlow iFlow) {
		// TODO Auto-generated method stub
		super.delete(iFlow);
	}

	@Override
	public void modiflyFlow(InformationFlow iFlow) {
		// TODO Auto-generated method stub
		super.update(iFlow);
	}
	@Override
	public InformationFlow getInformationFLowByInformationId(int informationId) {
		try{
			return (InformationFlow) super.find("from InformationFlow where informationId=? and isEnable=?", informationId,true).get(0);
		}catch(Exception e){
			return null;
		}		
	}
	@Override
	public List<InformationFlow> getInformationFLowByInforId(int informationId) {
		try{
			return super.find("from InformationFlow where informationId=?  and (lastFlowId >= 1 and lastFlowId<=4) and userName is not null", informationId);
		}catch(Exception e){
			return null;
		}	
	}

}
